$(document).ready(function() {
	/**
	 * caculate word count
	 *
	 * @author felixding
	 * @date 2010-03-11
	 */
	$('form#AddTweetForm textarea').bind('keyup keydown keypress focus click mousedown mouseup change', function() {
		//get word count
		word_count = $(this).val().length;
		
		//how many left?
		left_word_count = 140 - word_count;
		
		//update
		$('span#word_count').html(left_word_count);
		
		//switch styles
		if(left_word_count < 10) {
			$('span#word_count').addClass('word_count_highlight');
		}
		else {
			$('span#word_count').removeClass('word_count_highlight');
		}		
	});
	
	/**
	 * focus in form#AddTweetForm
	 *
	 * @author felixding
	 * @date 2010-03-11
	 */
	$('form#AddTweetForm textarea').focus();
});